<?php
/**
 * Description of Layout
 *
 * @author cybill
 */
class Plugins_Layout extends Zend_Controller_Plugin_Abstract {
    
    private $CONTENT = 'MAIN';
    
    public function preDispatch(\Zend_Controller_Request_Abstract $request) {
        parent::preDispatch($request);
        $module = $request->getModuleName();
        
        Zend_Layout::startMvc();
        $layout = Zend_Layout::getMvcInstance();
        
        $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
        $options = $bootstrap->getOptions();
        
        $layoutPATHTemp = $options['constant']['layoutPath'];
        $layoutPATH = $layoutPATHTemp . $module;
        
        if (!file_exists($layoutPATH . '/layout.phtml')) {
            $layoutPATH = $layoutPATHTemp . 'web';
        }
        
        $layout->setLayoutPath($layoutPATH)
                ->setLayout('layout');
    }
}

?>
